package com.sanjiahantang.youjiarole.module.join.models;

import android.content.Context;

import com.sanjiahantang.youjiarole.base.BaseBean;
import com.sanjiahantang.youjiarole.base.CallBack;
import com.sanjiahantang.youjiarole.config.ConfigValue;
import com.sanjiahantang.youjiarole.http.BaseDelegate;
import com.sanjiahantang.youjiarole.http.OkHttpClientManager;
import com.sanjiahantang.youjiarole.module.common.beans.StringBean;
import com.sanjiahantang.youjiarole.module.join.beans.CertificationResponseBean;
import com.squareup.okhttp.Request;

import java.util.Map;

/**
 * Created by zy on 2017/10/28.
 */

public class JoinModel implements IJoinModel {

    @Override
    public void findUserJoin(final Context context, Map<String, String> param, final CallBack<CertificationResponseBean> callBack) {
        OkHttpClientManager.postAsyn(context, ConfigValue.API_URL + "/user/phone/role/findUserJoin", param,
                new BaseDelegate.ResultCallback<CertificationResponseBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(CertificationResponseBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                },true);
    }

    @Override
    public void saveUserJoin(final Context context, Object param, final CallBack<BaseBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/user/phone/role/saveUserJoin", param,
                new BaseDelegate.ResultCallback<BaseBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(BaseBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }
}
